<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title data-i18n="resources.title_mb_deckglLayer_hexagonLayer"></title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript" include="papaparse,widgets" src="../js/include-web.js"></script>
<script type="text/javascript" include="deck" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<script type="text/javascript">

    var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090",
        url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
    var map, deckglLayer;
    var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
            " with <span>© <a href='http://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
            " Map Data <span>© <a href='https://uber.github.io/deck.gl' target='_blank'>deck.gl</a></span> ";

    map = new mapboxgl.Map({
        container: 'map',
        style: {
            "version": 8,
            "sources": {
                "raster-tiles": {
                    "attribution": attribution,
                    "type": "raster",
                    "tiles": [url + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
                    "tileSize": 256,
                },
            },
            "layers": [{
                "id": "simple-tiles",
                "type": "raster",
                "source": "raster-tiles",
                "minzoom": 0,
                "maxzoom": 22
            }]
        },
        center: [-122.430844, 37.772276],
        zoom: 12,
        pitch: 60,
        bearing: 36
    });
    map.addControl(new mapboxgl.NavigationControl(), 'top-left');

    widgets.loader.showLoader("data loading...");

    $.get('../data/deck.gl/sf-bike-parking.json', function (features) {
        widgets.loader.removeLoader();
        addLayer(features);
    });


    function addLayer(features) {

        deckglLayer = new mapboxgl.supermap.DeckglLayer("hexagon-layer", {
            data: features,
            props: {
                extruded: true, //是否拉伸要素，默认为 false；
                radius: 200, //六边形半径值，默认为 1000
                elevationScale: 4, //高程乘数
                coverage: 0.8 //六边形半径乘数，介于0 - 1之间。六边形的最终半径通过覆盖半径计算。
                //还可配置的参数：
                //colorRange 色带，默认为 [[255,255,178,255],[254,217,118,255],[254,178,76,255],[253,141,60,255],[240,59,32,255],[189,0,38,255]]
            },
            callback: {
                getPosition: d => d.COORDINATES,
            }
        });
        map.addLayer(deckglLayer);
    }

</script>
</body>
</html>
